package flc.ast.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.Random;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkEmptyProvider;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.bean.StkResBean;

public class HomeStrategyAdapter extends StkProviderMultiAdapter<StkResBean> {

    public HomeStrategyAdapter() {
        addItemProvider(new StkEmptyProvider<>(112));
        addItemProvider(new HomeStrategyProvider());
    }

    private class HomeStrategyProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_home_strategy;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getThumbUrl()).into((ImageView) baseViewHolder.getView(R.id.ivHomeStrategyImg));
            baseViewHolder.setText(R.id.tvHomeStrategyTitle, bean.getName());
            if (bean.getTagNameList()!=null||bean.getTagNameList().size()!=0){
                String tag="";
//                for (String s : bean.getTagNameList()) {
//                    tag+=s+" ";
//                }
                tag=bean.getTagNameList().get(bean.getTagNameList().size()-1);
                baseViewHolder.setText(R.id.tvHomeStrategyTag,tag);
            }
            Random random=new Random();
            int number=random.nextInt(20000)+1000;
            baseViewHolder.setText(R.id.tvHomeStrategyNum,getContext().getString(R.string.read_num,number));
        }
    }

}
